package com.region.http.client.resolver.result;

import com.region.common.utils.ReflectUtils;
import com.region.http.client.model.ResponseData;

import java.lang.reflect.Type;

/**
 * The string result resolver
 *
 * @author liujieyu
 * @date 2022/12/2
 * @description
 */
public class StringResultResolver extends AbstractResultResolver{

    @Override
    public boolean isResolver(Type type) {
        Class<?> returnClass = ReflectUtils.transform(type);
        return String.class.isAssignableFrom(returnClass);
    }

    @Override
    public Object resolver(ResponseData responseData) {
        return new String(responseData.getBody());
    }

    @Override
    public int getPriority() {
        return 100;
    }
}
